package com.ecloud.common.base.model;

import java.beans.Transient;
import java.io.Serializable;

/**
 * DTO基类 支持泛型主键
 *
 * @author LiuGangQiang Create in 2020/02/29
 */
@SuppressWarnings("serial")
public class BaseDto<PK extends Serializable> extends BaseAo {

    /**
     * 默认页数 默认值为 {@value}
     *
     * @author LiuGangQiang Create in 2020/02/29
     */
    private static final int DEFAULT_PAGE = 1;
    /**
     * 默认每页记录数 默认值为 {@value}
     *
     * @author LiuGangQiang Create in 2020/02/29
     */
    private static final int DEFAULT_ROWS = 10;
    /**
     * 主键
     *
     * @author LiuGangQiang Create in 2021/05/13
     */
    private PK id;

    /**
     * 当前页 默认值为 {@value #DEFAULT_PAGE}
     *
     * @author LiuGangQiang Create in 2020/02/29
     */
    private transient Integer page;

    /**
     * 每页记录数 默认值为 {@value #DEFAULT_PAGESIZE}
     *
     * @author LiuGangQiang Create in 2020/02/29
     */
    private transient Integer rows;
    /**
     * 关键字
     *
     * @author LiuGangQiang Create in 2021/04/25
     */
    private String keyword;

    /**
     * @return the id
     */
    public PK getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(PK id) {
        this.id = id;
    }

    /**
     * @return the page
     */
    @Transient
    public Integer getPage() {
        if (this.page != null && this.page > 0) {
            return page;
        }
        return DEFAULT_PAGE;
    }

    /**
     * @param page the page to set
     */
    public void setPage(Integer page) {
        this.page = page;
    }

    /**
     * @return the rows
     */
    public Integer getRows() {
        if (this.rows != null && this.rows > 0) {
            return rows;
        }
        return DEFAULT_ROWS;
    }

    /**
     * @param rows the rows to set
     */
    public void setRows(Integer rows) {
        this.rows = rows;
    }

    /**
     * @return the keyword
     */
    public String getKeyword() {
        return keyword;
    }

    /**
     * @param keyword the keyword to set
     */
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
}
